from django.conf.urls import url, include
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.routers import SimpleRouter

from meiduo_admin.views.sku_view import SKUViewSet, SKUCategoryView, SPUSimpleView
from .views.home_view import *
from .views.user_view import *
from .views.sku_view import *
from .views.spu_view import *
from .views.spec_view import *
from .views.option_view import *

urlpatterns = [
    url(r'^authorizations/$', obtain_jwt_token),
    url(r'^statistical/goods_day_views/$', GoodsVisitCountView.as_view()),
    url(r'^users/$', UserAPIView.as_view()),

    # url(r'^skus/$', SKUViewSet.as_view({"get": "list", "post": "create"})),
    # url(r'^skus/(?P<pk>\d+)/$', SKUViewSet.as_view({"get": "retrieve",
    #                                                 "put": "update",
    #                                                 "delete": "destroy"})),
    url(r'^skus/categories/$', SKUCategoryView.as_view()),
    url(r'^goods/simple/$', SPUSimpleView.as_view()),
    url(r'^goods/(?P<pk>\d+)/specs/$', SPUSpecView.as_view()),

    url(r'^goods/brands/simple/$', BrandSimpleView.as_view()),
    url(r'^goods/channel/categories/$', GoodsCategorySimpleView.as_view()),
    url(r'^goods/channel/categories/(?P<pk>\d+)/$', GoodsCategorySimpleView.as_view()),
    # url(r'^specs/options/$', OptionView.as_view({'get': 'list'})),
    url(r'^goods/specs/simple/$', OptionSimpleView.as_view()),

]


router = SimpleRouter()
router.register(prefix='statistical', viewset=HomeView, base_name='home')
router.register(prefix='goods/specs', viewset=SpecViewSet, base_name='home')
router.register(prefix='skus', viewset=SKUViewSet, base_name='skus')
router.register(prefix='goods', viewset=SPUViewSet, base_name='spu')
router.register(prefix='specs/options', viewset=OptionView, base_name='option')

urlpatterns += router.urls